package cn.zhz.springdoc.console.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.zhz.springdoc.console.mapper.IOpenApiMapper;
import cn.zhz.springdoc.console.po.OpenApiPo;
import cn.zhz.springdoc.console.vo.GroupVo;
import cn.zhz.springdoc.console.vo.ProjectVo;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ZHZ
 * @since 2022-11-15
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/project")
public class ProjectController {


    private final IOpenApiMapper iOpenApiMapper;

    @GetMapping("/list")
    public List<ProjectVo> list() {

        return iOpenApiMapper.selectList(Wrappers.lambdaQuery(OpenApiPo.class)
                .select(OpenApiPo::getProjectName))
                .stream().map(apiPo -> new ProjectVo(apiPo.getProjectName()))
                .distinct().collect(Collectors.toList());
    }
}
